const app = {
  state: {
    sidebar: {
      opened: false
    },
    dict: {},
    menu: [],
    auth: {},
    userinfo: {},
    vuexStore: false
  },
  mutations: {
    toggleSidebar: state => {
      state.sidebar.opened = !state.sidebar.opened
    },
    setDict: (state, dict) => {
      state.dict = {...dict};
    },
    setMenu: (state, menu) => {
      state.menu = [...menu];
    },
    setUserAuth: (state, auth) => {
      state.auth = {...auth};
    },
    setUserinfo: (state, userinfo) => {
      state.userinfo = {...userinfo}
    },
    setVuexStore: (state, value) => {
      state.vuexStore = value;
    }
  },
  actions: {
    toggleSideBar ({commit}) {
      commit('toggleSidebar')
    },
    setDict ({commit}, dict) {
      commit('setDict', dict);
    },
    setMenu ({commit}, menu) {
      commit('setMenu', menu);
    },
    setUserAuth ({commit}, auth) {
      commit('setUserAuth', auth);
    },
    setUserinfo ({commit}, userinfo) {
      commit('setUserinfo', userinfo);
    },
    setVuexStoreToTrue ({commit}) {
      commit('setVuexStore', true);
    },
    logoutClear ({commit}) {
      commit('setVuexStore', false);
      commit('setMenu', []);
      commit('setUserAuth', {});
      commit('setUserinfo', {});
      commit('setDict', {});
    }
  }
}

export default app
